//
//  NSString+XHLKit.h
//  XHLKit
//
//  Created by qinyulun on 16/6/18.
//  Copyright © 2016年 leTian. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef NS_ENUM(NSUInteger, CutType) {
    DoubleContainType,//两边都包含
    BeforeContainType,//只包含前面
    LaterContainType,//只包含后面
    NotContainType, //两边都不包含
};

@interface NSString (XHLKit)

+ (BOOL)isValidateEmail:(NSString *)email;//邮箱符合性验证。
+ (BOOL)isNumber:(NSString *)string;//全是数字。
+ (BOOL)isEnglishWords:(NSString *)string;//验证英文字母。
+ (BOOL)isValidatePassword:(NSString *)string;//验证密码：6—16位，只能包含字符、数字和 下划线。
+ (BOOL)isChineseWords:(NSString *)string;//验证是否为汉字。
+ (BOOL)isInternetUrl:(NSString *)string;//验证是否为网络链接。

//正确格式为：XXXX-XXXXXXX，XXXX-XXXXXXXX，XXX-XXXXXXX，XXX-XXXXXXXX，XXXXXXX，XXXXXXXX
+ (BOOL)isPhoneNumber:(NSString *)string;//验证是否为电话号码。
+ (BOOL)isElevenDigitNum:(NSString *)string;
+ (BOOL)isIdentifyCardNumber:(NSString *)string;//验证15或18位身份证。



/**
 *  截取字符串中两个位置之间的字符串
 *
 *  @param string  目标字符串
 *  @param start   开始字符串
 *  @param end     结束字符串
 *  @param contain 包含类型
 *
 *  @return
 */
+ (NSString *)searchInString:(NSString *)string
                   charStart:(NSString *)start
                     charEnd:(NSString *)end
                     contain:(CutType )contain;

/**
 *  截取字符串中两个位置之间的字符串
 *
 *  @param string  目标字符串
 *  @param start   开始字符串
 *  @param end     结束字符串
 *  @param contain 包含类型
 *
 *  @return
 */
- (NSString *)searchInString:(NSString *)string
                   charStart:(NSString *)start
                     charEnd:(NSString *)end
                     contain:(CutType )contain;

/**
 *  Create a MD5 string from self
 *
 *  @return Return the MD5 NSString from self
 */
//- (NSString *)MD5;

/**
 *  Create a SHA1 string from self
 *
 *  @return Return the SHA1 NSString from self
 */
//- (NSString *)SHA1;

/**
 *  Create a SHA256 string from self
 *
 *  @return Return the SHA256 NSString from self
 */
//- (NSString *)SHA256;

/**
 *  Create a SHA512 string from self
 *
 *  @return Return the SHA512 NSString from self
 */
//- (NSString *)SHA512;

/**
 *  判断是否包含某个字符串
 *
 *  @param substring The substring to be searched
 *
 *  @return Return YES if founded, NO if not
 */
- (BOOL)hasString:(NSString *)substring;

/**
 *  是否是eEmail
 *
 *  @return Return YES if it's an email, NO if not
 */
- (BOOL)isEmail;

/**
 *  是否是电话
 *  Add by Rain 20141230
 *  @return Return YES if it's an mobile phone, NO if not
 */
- (BOOL)isMobilePhone;

/**
 *  判断密码是否符合(6~18位)
 *
 *  @return BOLL
 */
- (BOOL)isFormattingPassword;
/**
 *  是否是eEmail
 *
 *  @param email The string to be checked
 *
 *  @return Return YES if it's an email, NO if not
 */
+ (BOOL)isEmail:(NSString *)email;

/**
 *  字符串 转 UTF8
 *
 *  @param string String to be converted
 *
 *  @return Return the converted string
 */
+ (NSString *)convertToUTF8Entities:(NSString *)string;

/**
 *  首字母大写
 *  Example: "This is a Test" will return "This is a test" and "this is a test"
 * will return "This is a test"
 *
 *  @return Return the capitalized sentence string
 */
- (NSString *)sentenceCapitalizedString;

/**
 *  Return a human legible string from a timestamp
 *
 *  @return Return a human legible string from a timestamp
 */
- (NSString *)dateFromTimestamp;

/**
 *  Encode self to an encoded url string
 *
 *  @return Return the encoded NSString
 */
- (NSString *)urlEncode;

/**
 *  Add by Rain 20141230
 */
- (NSDate *)string2Date:(NSString *)format;
- (BOOL)isIDCard;

@end
